-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
chore(docs): Fix syntax error in RBAC guide #12733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@benhovinga is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
I believe the proposed documentation update is incorrect. The So removing the ", ..." as proposed causes the user to be created in the database with ONLY the properties in the function. changing "..." to "...profile" causes the properties from the profile to be merged with the values set manually in the function. One other note, specific to the spread operator, is the order of statements with respect to the spread operator. When the spread operator is last, the properties of the profile (object being spread) from the IdP will override and matching property statement manually set -- this seems safest as a pattern such that the IdP identity information is most accurate. If the spread operator is first, then any manually set properties will override matching properties returned from the IdP profile. (This would only be appropriate if there was a valid reason to change an IdP provided value -- which arguably should not be done.) While not applicable to the role property because it does not exist in the profile, this is an important note in my opinion as it can be a source of confusion to newer devs (maybe link out to spread operator documentation here?) |
Ah, this makes more sense. Usually when I see So this should be the correct version export const { handlers, auth } = NextAuth({
providers: [
Google({
profile(profile) {
return { role: profile.role ?? "user", ...profile }
},
})
],
}) When I get on my dev machine I will update the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
EDIT: Ah just read the comments. Not sure if it was meant as a spread operator where the author just forgot the profile
part. But that should ideally be there, so let's go that route.
If you update it I can get this merged. Sorry for the delay!
Corrected the spread operator to |
☕️ Reasoning
Moved the Ellipsis ( ... ) onto a separate line as a comment. The Ellipsis was throwing "Expression Expected" error. I assume this was used to indicate to the developer that more properties can be added here. Moving it inside of a comment performs the same function without throwing any errors.
Before
After
This fix has been applied to all frameworks.
🧢 Checklist
🎫 Affected issues
Fixes: #12462
📌 Resources